﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace QuanLyBanHang
{
    public partial class frmSaoLuuDuLieu : Form
    {
        public frmSaoLuuDuLieu()
        {
            InitializeComponent();
            lblPath.Text = "";
        }

        private void btnChonPath_Click(object sender, EventArgs e)
        {
            saveFileDialog1.FileName = "Đặt tên cho file";
            saveFileDialog1.Title = "Chọn nơi cần sao lưu dữ liệu";
            saveFileDialog1.Filter = "Dữ liệu (*.mdf)|*.mdf";
            saveFileDialog1.ShowDialog();
            if (saveFileDialog1.ShowDialog() != DialogResult.Cancel)
            {
                lblPath.Text = saveFileDialog1.FileName;
            }
        }

        private void btnLuu_Click(object sender, EventArgs e)
        {
            try
            {
                StreamWriter sw = new StreamWriter("Config.ini", false);
                sw.WriteLine(string.Format("{0}\t{1}\t{2}\t{3}",
                    dtpNgay.Value.ToString("dd/MM/yyyy"),
                    dtpGio.Value.ToString("HH:mm"), "False", lblPath.Text));
                sw.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            this.Close();
        }

        protected override bool ProcessDialogKey(Keys keyData)
        {
            if (keyData == Keys.Escape)
            {
                this.Close();
                return base.ProcessDialogKey(keyData);
            }
            else
                return false;
        }
    }
}
